<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Chi tiết sách</title>
</head>

<body>

  <?php
				@session_start();
				if(isset($_GET["themgiohang"]))
				{
					$id=$_GET["themgiohang"];
					if(isset($_SESSION['giohang']) && is_array($_SESSION['giohang']))
					{
						$count= count($_SESSION['giohang']);
						$flag=false;
						for ($i = 0; $i < $count; $i++)
						{ 
						if($_SESSION['giohang'][$i]["id"] == $id){
							$_SESSION['giohang'][$i]["soluong"] +=1;
									$flag=true;
									break;
							}
							}
						if($flag == false)
						{$_SESSION['giohang'][$count]["id"]=$id;
							$_SESSION['giohang'][$count]["soluong"]=1;
							}
						}else {
							$_SESSION['giohang']=array();
							$_SESSION['giohang'][0]["id"]=$id;
							$_SESSION['giohang'][0]["soluong"]=1;
							echo "<script> comfirm('Please enter some text!');</script>";

							}
						header("Location: cts.php?id=".$id."");
						$sl = $_SESSION['giohang'][0]["soluong"];
						echo "yyyyyyyyyy".$sl;
				}

?>
<?PHP
   
	require ('admin/models/m_sach.php'); 
	require ('admin/models/sharefunction.php'); 
	include ('login.php');
	$getid= $_GET['id'];
	$s=getbyid_sach($_GET['id']);
	$nxb=getbyid_nxb($s['ID_Nha_xuat_ban']);
	$cd=getbyid_cd($s['ID_Chu_de']);
	$tg=getbyid_tg($s['ID']);
	$gb = getbyid_gb($s['ID']);
	$gg = getbyid_gg($s['ID_Giam_gia']);
	$binhluan = getbyid_binhluan($getid);
	$cookieName=0;
	
	if(!isset($_COOKIE["$cookieName"]))
		{
		setcookie("$cookieName","1",time()+3600);
		mysql_query("UPDATE `sach` SET `Luot_xem`=`Luot_xem`+1 WHERE `id`='$getid' ");
		}
if (isset($_POST['guibl']))
			{  
				insert_binhluansach($_POST,$getid); 
				
			  
			}
	require ('v_cts.php'); 
	
?>
</body>
</html>